<?php require APP_ROOT.'public/top.php';?>
<div class="admincp-container unfold">
<?php require APP_ROOT.'public/left.php';?>
<?php
	$type_id=pg('type_id');
?>

<div class="right-nav">

<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3> 新增</h3>
        <h5>新增内容</h5>
      </div>
    </div>
  </div>
    <!--表单数据-->
<form action="index.php?m=cms&a=add_save" method="post" enctype="multipart/form-data" id="handleposition" onsubmit="return return_message()">
<input name="data[date]" type="hidden" id="date" value="<?php echo time();?>" />
<input name="data[version_id]" type="hidden" id="version_id" value="1" />
<input name="data[type_id]" type="hidden" id="type_id" value="<?php echo $type_id;?>" />
<input name="data[member_id]" type="hidden" id="member_id" value="<?php echo $member['member_id'];?>" />
<input name="data[state]" type="hidden" id="state" value="1" />
    <div class="ncap-form-default">
    <?php
$list = M('input')->where(array('type_id'=>$type_id,'show_switch'=>2,'input_pid'=>array('exp','is null')))->order('date asc')->select();
foreach($list as $k=>$v){
?>
      <dl class="row">
        <dt class="tit">
          <label><em>*</em><?php echo $v['input_name']?>：</label>
        </dt>
        <dd class="opt">
        <?php
	switch($v['input_type_id']){
		case 1:
		?>
        <input name="data[<?php echo $v['field_name'];?>]" type="text" id="<?php echo $v['field_name'];?>" size="80" />
        <?php
		break;
		case 2:
		?>
        <textarea name="data[<?php echo $v['field_name'];?>]" cols="60" rows="<?php echo $v['edit_size'];?>" id="<?php echo $v['field_name'];?>"></textarea>
        <?php
		break;
		case 3:
			echo fckeditor('data['.$v['field_name'].']',$v['edit_size'],'');
		break;
		case 4:
		?>
        <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
        <label>
        <input type="checkbox" name="data[<?php echo $v['field_name'];?>][]" value="<?php echo $v2['input_value']?>" />
        <?php echo $v2['input_name'];?>
        </label>&nbsp;&nbsp;
        <?php } ?>
        <?php
		break;
		case 5:
		?>
        <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
        <label>
        <input type="radio" name="data[<?php echo $v['field_name'];?>]" value="<?php echo $v2['input_value']?>" />
        <?php echo $v2['input_name'];?>
        </label>&nbsp;&nbsp;
        <?php } ?>
        <?php
		break;
		case 6:
		?>
        <select name="data[<?php echo $v['field_name'];?>]" id="<?php echo $v['field_name'];?>">
        <option value="0">请选择</option>
        <?php
		$input_p = M('input')->where(array('input_pid'=>$v['input_id']))->select();
		foreach($input_p as $k2=>$v2){
		?>
          <option value="<?php echo $v2['input_value'];?>"><?php echo $v2['input_name'];?></option>
        <?php } ?>
        </select>
        <?php
		break;
		case 7:
		?>
        <input name="<?php echo $v['field_name'];?>" id="<?php echo $v['field_name'];?>" type="file" />
        <?php
		break;
		case 8:
		?>
        <input name="data[<?php echo $v['field_name'];?>]" class="laydate-input" type="text" id="<?php echo $v['field_name'];?>" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" size="<?php echo $v['edit_size'];?>" />
        <?php
		break;
		case 9:
			$field_name=$v['field_name'];
		?>
		<div class="fieldset flash" id="fsUploadProgress" align="left"></div>
        <div id="divStatus">0 个文件已上传</div>
        <div> <span id="spanButtonPlaceHolder"></span><br />
          <input id="btnCancel" type="button" value="断开上传" onClick="swfu.cancelQueue();" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
        </div>
        <input name="data[<?php echo $v['field_name'];?>]" type="hidden" id="<?php echo $v['field_name'];?>" size="<?php echo $v['edit_size'];?>" />
		<?php
		break;
	}
	?>
    
    
    
		  <span class="err" id="err_ad_name" style="color:#F00; display:none;"><?php echo $v['note'];?></span>                                                  
          <p class="notic"></p>
        </dd>
      </dl>
   <?php }?>
      
      
      
      
      
      
      
            <div class="bot"><a href="JavaScript:void(0);" onclick="adsubmit()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
    </div>
       <input type="hidden" name="act" value="add">
       <input type="hidden" name="ad_id" value="">
  </form>
</div>
<script>
	 function adsubmit(){
		$('#handleposition').submit();
	}

function return_message()
{
	<?php  $input = M('input')->where(array('type_id'=>$type_id,'show_switch'=>2,'required_switch'=>2,'input_pid'=>array('exp','is null')))->order('date asc')->select();  foreach($input as $k=>$v){?>
	if($("#<?php echo $v['field_name'];?>").val()=='')
	{
		alert("<?php echo $v['prompt'];?>");
		return false;
	}
	<?php }?>
}

</script>
</div>
</div>

<?php require APP_ROOT.'public/foot.php';?>
